﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_AddJump_V3]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_AddJump_V3];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_AddJump_V3]
    @FlowID int,
    @StepID int,
    @FieldName nvarchar(50),
    @Compare nvarchar(50),
    @CompareValue numeric(9,2),
    @ToFlowID int = 0,
    @ToStepID int,
    @FlowRule int = 0
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;

-- get the default priority
DECLARE @Priority INT;
SELECT @Priority = ISNULL(MAX(Priority), 0) + 1 FROM dbo.UDS_Flow_Jump WHERE Flow_ID = @FlowID and Step_ID = @StepID;

INSERT INTO dbo.UDS_Flow_Jump(Priority, Fieldname, Compare, Comparevalue, Flow_id, Step_id, To_Flow_id, To_step_id, Flow_Rule)
    VALUES(@Priority, @FieldName, @compare, @comparevalue, @flowid, @stepid, @ToFlowID, @ToStepID, @FlowRule)

RETURN 0

END
GO